package com.gusti.turnos.util;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

/**
 * 
 * @author gusti
 *
 */
public class Debug {

	public static boolean debugActivated = true;

	/**
	 * 
	 * @param log
	 * 		message to log into console
	 */
	public static void log( String log ){
		if( debugActivated && log != null ){
			System.out.println( "[ " + getDateTime() + " ] INFO: " + log );
		}
	}

	/**
	 * 
	 * @param e
	 * 		exception to log into console
	 */
	public static void error( Exception e ){
		if( debugActivated && e != null ){
			System.out.println( "[ " + getDateTime() + " ] ERROR: " + e.getClass().toString() + " | " + e.getMessage() );
		}
	}

	private static String getDateTime() {
		GregorianCalendar gregorianCalendar = new GregorianCalendar();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

		return simpleDateFormat.format( gregorianCalendar.getTime() );
	}
}
